package org.elcom.source;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Config {
    public static String address = "";
    public static int port = 0;
    public static String sid = "";
    public static String userName = "";
    public static String password = "";
    
    public static String formatOfDate = "";
    public static String sourceDir = "";
    public static String okDir = "";
    
	public static int time = 5000;
	public static int batchSize = 1000;
	
    public Config(){
        Properties pro = new Properties();
            try {
                    pro.load(new FileInputStream("C:/configO.txt"));
            } catch (FileNotFoundException e) {
                    System.out.println("Cannot find the file config.txt");
            } catch (IOException e) {
                    System.out.println("Error to read file config.txt");
            } catch (Exception e) {
                    System.out.println("Error");
            }

            address = pro.getProperty("ADDRESS").toString().trim();
            port = Integer.parseInt(pro.getProperty("PORT"));
            sid = pro.getProperty("SID").toString().trim();
            userName = pro.getProperty("USERNAME").toString().trim();
            password = pro.getProperty("PASSWORD").toString().trim();
            formatOfDate = pro.getProperty("FORMATOFDATE").toString().trim();
            sourceDir = pro.getProperty("SOURCEDIR").toString().trim();
            okDir = pro.getProperty("OKDIR").toString().trim();
            
//            createTmpFolder(tmpDir);
            createOKFolder(okDir);
    }

	private void createOKFolder(String ok) {
		File file = new File(ok);
        if (!file.exists()) {
            file.mkdirs();
        }
	}
}
